package cn.jsu.oj.dispatchServer.satellite.handler;

import cn.jsu.oj.dispatchServer.satellite.annotation.HandlerType;
import cn.jsu.oj.dispatchServer.satellite.pojo.net.PackNet;
import cn.jsu.oj.dispatchServer.satellite.pojo.net.ResponseNet;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * 委托响应处理器
 *
 * @author shan
 * @date 2022/07/03
 */
@Slf4j
@Component("responseHandler")
@HandlerType(typeNo = 4)
public class ResponseHandler implements Handler {

    @Override
    public void handle(PackNet<?> packNet) {
        ResponseNet responseNet = (ResponseNet) packNet.getMessage();
        try {
            packNet.getChannel().writeAndFlush(responseNet.serialize());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
